/*
 * @Author: your name
 * @Date: 2021-04-17 17:30:39
 * @LastEditTime: 2021-04-17 19:58:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /flutter_demo/lib/pages/StoragePage.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_demo/utils/storage.dart';

class StoragePage extends StatefulWidget {
  @override
  _StoragePageState createState() => _StoragePageState();
}

class _StoragePageState extends State<StoragePage> {
  _saveData() async {
    await Storage.setString('age', '17');
  }

  _getData() async {
    var res = await Storage.getString('age');
    print(res);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('本地存储'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(onPressed: _saveData, child: Text('存储数据')),
              ElevatedButton(onPressed: _getData, child: Text('获取数据'))
            ],
          ),
        ));
  }
}
